﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Caching;
using System.Text;
using System.Threading.Tasks;

namespace Infrastructure.Cache.CacheItemPolicyPackage
{
    internal class SlidingCacheItemPolicy : ICacheItemPolicy
    {
        private readonly TimeSpan _expireTimeSpan;

        internal SlidingCacheItemPolicy(TimeSpan expireTimeSpan)
        {
            _expireTimeSpan = expireTimeSpan;
        }

        internal SlidingCacheItemPolicy(int seconds) : this(new TimeSpan(0, 0, seconds))
        {
        }

        CacheItemPolicy ICacheItemPolicy.GetCacheItemPolicy()
        {
            return new CacheItemPolicy() { SlidingExpiration = _expireTimeSpan };
        }
    }
}
